package com.icloud.common;


import com.icloud.common.constant.InvokeStatus;
import com.icloud.common.exception.AbstractException;

public class InvokeResult<T> {
	private T data;
	private String message;
	private int status;
	private boolean hasErrors;


	public  InvokeResult(){
		this.status = InvokeStatus.OK.getValue();
		this.hasErrors = false;
	};

	public InvokeResult(T data){
		this.data = data;
		this.status = InvokeStatus.OK.getValue();
		this.hasErrors = false;
	}
	public InvokeResult(AbstractException e){
		this.hasErrors = true;
		this.message = e.getMessage();
		this.status  = e.getInvokeStatus().getValue();

	}

	public T getData() {
		return data;
	}

	public String getMessage() {
		return message;
	}

	public boolean isHasErrors() {
		return hasErrors;
	}

	public boolean isSuccess() {
		return !hasErrors;
	}

	public int getStatus() {
		return status;
	}
}
